package cn.gson.querydsl.config;

import org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;

/**
 * <p>****************************************************************************</p>
 * <p><b>Copyright © 2010-2024 纷析云（株洲）科技有限公司 All Rights Reserved<b></p>
 * <ul style="margin:15px;">
 * <li>Description : 物理表名前缀处理</li>
 * <li>Version     : 1.0</li>
 * <li>Creation    : 2024年06月2日</li>
 * <li>@author     : ____′↘夏悸</li>
 * </ul>
 * <p>****************************************************************************</p>
 */
public class PhysicalNamingStrategy extends CamelCaseToUnderscoresNamingStrategy {

    @Override
    public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) {
        Identifier identifier = super.toPhysicalTableName(name, jdbcEnvironment);
        return new Identifier("v_" + identifier.getText(), true);
    }

    @Override
    public Identifier toPhysicalColumnName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
        Identifier identifier = super.toPhysicalColumnName(logicalName, jdbcEnvironment);
        return new Identifier(identifier.getText(), true);
    }
}
